/*
 * @Author: DONGDONG
 * @Date: 2022-01-17 22:32:20
 * @LastEditTime: 2022-01-19 14:42:00
 * @LastEditors: DONGDONG
 * @FilePath: \lagoufed-e-task\part1\fed-e-task-01-01\code\code1.js
 */
/*
  将下面异步代码使用 Promise 的方法改进
  尽量用看上去像同步代码的方式
  setTimeout(function () {
    var a = 'hello'
    setTimeout(function () {
      var b = 'lagou'
      setTimeout(function () {
        var c = 'I ♥ U'
        console.log(a + b +c)
      }, 10)
    }, 10)
  }, 10)
*/

let myPromise = () => {
	return new Promise((resolved, rejected) => {
		setTimeout(function () {
			resolved()
		}, 10)
	})
}

const p = async () => {
	await myPromise()
	var a = 'hello'
	await myPromise()
	var b = 'lagou'
	await myPromise()
	var c = 'I ♥ U'
	console.log(a + b + c)
}

p()
